package com.baitiaojun.video.feign;

import com.baitiaojun.api.domain.video.Video;
import com.baitiaojun.api.domain.video.VideoChildComment;
import com.baitiaojun.api.domain.video.VideoComment;
import com.baitiaojun.api.exception.ConditionException;
import com.baitiaojun.api.vo.JsonRes;
import com.baitiaojun.api.vo.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Set;

/**
 * @类名 ElasticsearchVideoFeign
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2022/12/20 23:31
 * @版本 1.0
 */
@FeignClient(name = "imooc-bilibili-elasticsearch", path = "/elasticsearch")
public interface ElasticsearchVideoFeign {

    @PostMapping("/new-video")
    void saveVideo(@RequestBody Video video) throws ConditionException;

    @PostMapping("/new-video-comment")
    JsonRes saveVideoComment(@RequestBody VideoComment videoComment) throws ConditionException;

    @PostMapping("/new-child-video-comment")
    JsonRes saveChildVideoComment(@RequestBody VideoChildComment videoChildComment) throws ConditionException;

    @GetMapping("parent-video-comment")
    VideoComment getParentVideoComment(@RequestParam("id") Long id, @RequestParam("videoId") Long videoId);

    @GetMapping("/parent-video-comment-list")
    List<VideoComment> getParentVideoCommentList(@RequestParam("pageNo") Integer pageNo, @RequestParam("size") Integer size, @RequestParam("videoId") Long videoId);

    @GetMapping("/child-video-comment-list")
    List<VideoChildComment> getChildVideoCommentList(@RequestParam("ids") Set<Long> ids);

    @GetMapping("/page-child-video-comment-list")
    PageInfo getPageChildVideoCommentList(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestParam("videoId") Long videoId, @RequestParam("rootId") Long rootId);

    @DeleteMapping("/cancel-video-child-comment")
    void removeVideoChildComment(@RequestParam("id") Long id);

    @DeleteMapping("/cancel-video-comment")
    void removeVideoComment(@RequestParam("id") Long id);

    @GetMapping("/search-video-comment-list")
    List<VideoComment> getVideoCommentList(@RequestParam("userId") Long userId) throws IOException;

    @GetMapping("/search-video-child-comment-list")
    List<VideoChildComment> getVideoChildCommentList(@RequestParam("ids") Set<Long> ids);

    @PutMapping("/update-view-count")
    void updateViewCount(@RequestBody List<Long> videoIds) throws IOException;

    @GetMapping("/home-video")
    List<Video> getPageHomeVideoList(@RequestParam("lastId") Long lastId
            , @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "area") String... area) throws IOException;

    @DeleteMapping("/cancel-video")
    void removeVideo(@RequestParam("id") Long id);
}
